package com.tiancheng.trade.commom.core.exception.assertion;


import com.tiancheng.trade.commom.core.exception.AuthorizationException;
import com.tiancheng.trade.commom.core.exception.BaseException;
import com.tiancheng.trade.commom.core.exception.error.IErrorInfo;

import java.text.MessageFormat;

/**
 * 认证异常，业务异常错误信息枚举类都实现此接口
 *
 * @author kellen
 * @date 2019-09-03
 */
public interface AuthExceptionAssert extends IErrorInfo, Assert {

    @Override
    default BaseException newException(Object... args) {
        String msg = MessageFormat.format(this.getMessage(), args);

        return new AuthorizationException(this, args, msg);
    }

    @Override
    default AuthorizationException newException(Throwable t, Object... args) {
        String msg = MessageFormat.format(this.getMessage(), args);

        return new AuthorizationException(this, args, msg, t);
    }

}
